<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php /* @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Checkbox */ ?>
<?php $_option = $block->getOption(); ?>
<?php $_selections = $_option->getSelections(); ?>
<?php $_skipSaleableCheck = $this->helper('Magento\Catalog\Helper\Product')->getSkipSaleableCheck(); ?>

<div class="field admin__field options<?php if ($_option->getRequired()) echo ' required _required' ?>">
    <label class="label admin__field-label">
        <span><?php echo $block->escapeHtml($_option->getTitle()) ?></span>
    </label>

    <div class="control admin__field-control">
        <div class="nested <?php if ($_option->getDecoratedIsLast()):?> last<?php endif;?>">

            <?php if (count($_selections) == 1 && $_option->getRequired()): ?>
                <?php /* @escapeNotVerified */ echo $block->getSelectionQtyTitlePrice($_selections[0]) ?>
                <input type="hidden"
                       name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>]"
                       value="<?php /* @escapeNotVerified */ echo $_selections[0]->getSelectionId() ?>"
                       price="<?php /* @escapeNotVerified */ echo $block->getSelectionPrice($_selections[0]) ?>" />
            <?php else:?>

                <?php foreach ($_selections as $_selection): ?>
                    <div class="field choice admin__field admin__field-option">
                        <input
                            class="change-container-classname admin__control-checkbox checkbox bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?> <?php if ($_option->getRequired()) echo 'validate-one-required-by-name' ?>"
                            id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>"
                            type="checkbox"
                            name="bundle_option[<?php /* @escapeNotVerified */ echo $_option->getId() ?>][<?php /* @escapeNotVerified */ echo $_selection->getId() ?>]"
                            <?php if ($block->isSelected($_selection)):?>
                                <?php echo ' checked="checked"'; ?>
                            <?php endif;?>
                            <?php if (!$_selection->isSaleable() && !$_skipSaleableCheck):?>
                                <?php echo ' disabled="disabled"'; ?>
                            <?php endif;?>
                            value="<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>"
                            onclick="ProductConfigure.bundleControl.changeSelection(this)"
                            price="<?php /* @escapeNotVerified */ echo $block->getSelectionPrice($_selection) ?>" />

                        <label class="admin__field-label"
                               for="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-<?php /* @escapeNotVerified */ echo $_selection->getSelectionId() ?>">
                            <span><?php /* @escapeNotVerified */ echo $block->getSelectionQtyTitlePrice($_selection) ?></span>
                        </label>

                        <?php if ($_option->getRequired()): ?>
                            <?php /* @escapeNotVerified */ echo $block->setValidationContainer('bundle-option-' . $_option->getId() . '-' . $_selection->getSelectionId(), 'bundle-option-' . $_option->getId() . '-container') ?>
                        <?php endif;?>
                    </div>
                <?php endforeach; ?>

                <div id="bundle-option-<?php /* @escapeNotVerified */ echo $_option->getId() ?>-container"></div>
            <?php endif; ?>
        </div>
    </div>
</div>
